﻿using LPY.LeHealth.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace LPY.LeHealth.DAL
{
    using ServiceStack.OrmLite;
    public class ZuheComboDAL:BaseDAL
    {
        /// <summary>
        /// 显示前几条组合套餐数据
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public List<ZuhetoCombo> GetZuhe(int num)
        {
            string constring = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
            using(SqlConnection cnn=new SqlConnection(constring))
            {

                string sql = "select zc.Id,c.Name,c.Price,zc.Zname from t_combo c join t_zuhetocombo ztc on c.Id=ztc.Cid join t_zuhecombodto zc on ztc.Zid=zc.Id where ztc.Zid=" + num + "";
                
                SqlCommand command = new SqlCommand(sql,cnn);
                cnn.Open();
                SqlDataReader reader = command.ExecuteReader();
                List<ZuhetoCombo> list = new List<ZuhetoCombo>();
                while (reader.Read())
                {    ZuhetoCombo ztc = new ZuhetoCombo();
                    ztc.Zid = Convert.ToInt32(reader["Id"]);
                    ztc.Name = reader["Name"].ToString();
                    ztc.Price =Convert.ToDecimal( reader["Price"]);
                    ztc.Zname = reader["Zname"].ToString();
                    list.Add(ztc);
                }
                return list; 

               
            }
        }
    }
}
